package com.hushao.aimi.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * @description: 地址信息
 * @author: 胡少
 * @create: 2018-06-03 17:38
 **/
@ApiModel("地址信息")
@Data
@Entity
public class AimiAddress implements Serializable {
    @Id
    @GenericGenerator(name = "uuid",strategy = "uuid")
    @GeneratedValue(generator = "uuid")
    @Column(length = 32)
    private String id;

    /**
     * 用户id
     */
    @Column(length = 32,nullable = false)
    private String userId;

    /**
     * 收货姓名
     */
    @NotNull(message = "收货姓名不能为空！")
    @Column(length = 16,nullable = false)
    private String receiverName;

    /**
     * 收货号码
     */
    @NotNull(message = "收货号码不能为空")
    @Pattern(regexp = "^[1](([3][0-9])|([4][5,7,9])|([5][^4,6,9])|([6][6])|([7][3,5,6,7,8])|([8][0-9])|([9][8,9]))[0-9]{8}$",message = "手机号码格式错误")
    @Column(length = 11,nullable = false)
    private String receiverPhone;

    /**
     * 收货省份
     */
    @NotNull(message = "收货省份不能为空！")
    @Column(length = 16,nullable = false)
    private String receiverProvince;

    /**
     * 收货城市
     */
    @NotNull(message = "收货城市不能为空！")
    @Column(length = 16,nullable = false)
    private String receiverCity;

    /**
     * 收货区/县
     */
    @NotNull(message = "收货区/县不能为空！")
    @Column(length = 32,nullable = false)
    private String receiverDistrict;

    /**
     * 市区编号
     */
    @Column(length = 8,nullable = false)
    private String areaCode;

    /**
     * 收货详细地址
     */
    @NotNull(message = "收货详细地址不能为空！")
    @Column(length = 256,nullable = false)
    private String receiverAddress;

    /**
     * 收货邮编
     */
    @Column(length = 6)
    private String receiverZipCode;

    @CreationTimestamp
    private Timestamp createTime;

    @UpdateTimestamp
    private Timestamp updateTime;

    @Column(length = 512)
    private String comment;


    public AimiAddress(String userId, @NotNull(message = "收货姓名不能为空！") String receiverName, @NotNull(message = "收货号码不能为空") @Pattern(regexp = "^((13[0-9])|(15[^4,\\\\D])|(18[0,5-9]))\\\\d{8}$和^[1]([3][0-9]{1}|59|58|88|89)[0-9]{8}$", message = "手机号码格式错误") String receiverPhone, @NotNull(message = "收货省份不能为空！") String receiverProvince, @NotNull(message = "收货城市不能为空！") String receiverCity, @NotNull(message = "收货区/县不能为空！") String receiverDistrict, @NotNull(message = "收货详细地址不能为空！") String receiverAddress, String receiverZipCode, String areaCode,String comment) {
        this.userId = userId;
        this.receiverName = receiverName;
        this.receiverPhone = receiverPhone;
        this.receiverProvince = receiverProvince;
        this.receiverCity = receiverCity;
        this.receiverDistrict = receiverDistrict;
        this.receiverAddress = receiverAddress;
        this.receiverZipCode = receiverZipCode;
        this.areaCode=areaCode;
        this.comment = comment;
    }

    public AimiAddress(String id,String userId, @NotNull(message = "收货姓名不能为空！") String receiverName, @NotNull(message = "收货号码不能为空") @Pattern(regexp = "^((13[0-9])|(15[^4,\\\\D])|(18[0,5-9]))\\\\d{8}$和^[1]([3][0-9]{1}|59|58|88|89)[0-9]{8}$", message = "手机号码格式错误") String receiverPhone, @NotNull(message = "收货省份不能为空！") String receiverProvince, @NotNull(message = "收货城市不能为空！") String receiverCity, @NotNull(message = "收货区/县不能为空！") String receiverDistrict, @NotNull(message = "收货详细地址不能为空！") String receiverAddress, String receiverZipCode, String areaCode,String comment) {
        this.id=id;
        this.userId = userId;
        this.receiverName = receiverName;
        this.receiverPhone = receiverPhone;
        this.receiverProvince = receiverProvince;
        this.receiverCity = receiverCity;
        this.receiverDistrict = receiverDistrict;
        this.receiverAddress = receiverAddress;
        this.receiverZipCode = receiverZipCode;
        this.areaCode=areaCode;
        this.comment = comment;
    }
}
